<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class date</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../date_time/doxy.html#header.boost.date_time.gregorian.greg_date_hpp" title="Header &lt;boost/date_time/gregorian/greg_date.hpp&gt;">
<link rel="prev" href="gregorian_calendar.html" title="Class gregorian_calendar">
<link rel="next" href="bad_day_of_month.html" title="Struct bad_day_of_month">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="gregorian_calendar.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.gregorian.greg_date_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bad_day_of_month.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.gregorian.date"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class date</span></h2>
<p>boost::gregorian::date — A date type based on <a class="link" href="gregorian_calendar.html" title="Class gregorian_calendar">gregorian_calendar</a>. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../date_time/doxy.html#header.boost.date_time.gregorian.greg_date_hpp" title="Header &lt;boost/date_time/gregorian/greg_date.hpp&gt;">boost/date_time/gregorian/greg_date.hpp</a>&gt;

</span>
<span class="keyword">class</span> <a class="link" href="date.html" title="Class date">date</a> <span class="special">:</span>
  <span class="keyword">public</span> <span class="identifier">date_time</span><span class="special">::</span><span class="identifier">date</span><span class="special">&lt;</span> <span class="identifier">date</span><span class="special">,</span> <span class="identifier">gregorian_calendar</span><span class="special">,</span> <span class="identifier">date_duration</span> <span class="special">&gt;</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">gregorian_calendar</span><span class="special">::</span><span class="identifier">year_type</span>        <a name="boost.gregorian.date.year_type"></a><span class="identifier">year_type</span><span class="special">;</span>       
  <span class="keyword">typedef</span> <span class="identifier">gregorian_calendar</span><span class="special">::</span><span class="identifier">month_type</span>       <a name="boost.gregorian.date.month_type"></a><span class="identifier">month_type</span><span class="special">;</span>      
  <span class="keyword">typedef</span> <span class="identifier">gregorian_calendar</span><span class="special">::</span><span class="identifier">day_type</span>         <a name="boost.gregorian.date.day_type"></a><span class="identifier">day_type</span><span class="special">;</span>        
  <span class="keyword">typedef</span> <span class="identifier">gregorian_calendar</span><span class="special">::</span><span class="identifier">day_of_year_type</span> <a name="boost.gregorian.date.day_of_year_type"></a><span class="identifier">day_of_year_type</span><span class="special">;</span>
  <span class="keyword">typedef</span> <span class="identifier">gregorian_calendar</span><span class="special">::</span><span class="identifier">ymd_type</span>         <a name="boost.gregorian.date.ymd_type"></a><span class="identifier">ymd_type</span><span class="special">;</span>        
  <span class="keyword">typedef</span> <span class="identifier">gregorian_calendar</span><span class="special">::</span><span class="identifier">date_rep_type</span>    <a name="boost.gregorian.date.date_rep_type"></a><span class="identifier">date_rep_type</span><span class="special">;</span>   
  <span class="keyword">typedef</span> <span class="identifier">gregorian_calendar</span><span class="special">::</span><span class="identifier">date_int_type</span>    <a name="boost.gregorian.date.date_int_type"></a><span class="identifier">date_int_type</span><span class="special">;</span>   
  <span class="keyword">typedef</span> <a class="link" href="date_duration.html" title="Class date_duration">date_duration</a>                        <a name="boost.gregorian.date.duration_type"></a><span class="identifier">duration_type</span><span class="special">;</span>   

  <span class="comment">// <a class="link" href="date.html#boost.gregorian.dateconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_13-bb"><span class="identifier">date</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_14-bb"><span class="identifier">date</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">,</span> <span class="identifier">month_type</span><span class="special">,</span> <span class="identifier">day_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">explicit</span> <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_15-bb"><span class="identifier">date</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">ymd_type</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">explicit</span> <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_16-bb"><span class="identifier">date</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">date_int_type</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">explicit</span> <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_17-bb"><span class="identifier">date</span></a><span class="special">(</span><span class="identifier">date_rep_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">explicit</span> <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_18-bb"><span class="identifier">date</span></a><span class="special">(</span><span class="identifier">special_values</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_12-bb">public member functions</a></span>
  <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">date_int_type</span> <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_12_1-bb"><span class="identifier">julian_day</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">day_of_year_type</span> <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_12_2-bb"><span class="identifier">day_of_year</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">date_int_type</span> <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_12_3-bb"><span class="identifier">modjulian_day</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="keyword">int</span> <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_12_4-bb"><span class="identifier">week_number</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">date_int_type</span> <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_12_5-bb"><span class="identifier">day_number</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">BOOST_CXX14_CONSTEXPR</span> <a class="link" href="date.html" title="Class date">date</a> <a class="link" href="date.html#id-1_3_14_15_4_6_1_1_1_12_6-bb"><span class="identifier">end_of_month</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.14.15.4.6.3.4"></a><h2>Description</h2>
<p>This class is the primary interface for programming with greogorian dates. The is a lightweight type that can be freely passed by value. All comparison operators are supported. </p>
<div class="refsect2">
<a name="id-1.3.14.15.4.6.3.4.3"></a><h3>
<a name="boost.gregorian.dateconstruct-copy-destruct"></a><code class="computeroutput">date</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_14_15_4_6_1_1_1_13-bb"></a><span class="identifier">date</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Default constructor constructs with not_a_date_time. </li>
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_14_15_4_6_1_1_1_14-bb"></a><span class="identifier">date</span><span class="special">(</span><span class="identifier">year_type</span> y<span class="special">,</span> <span class="identifier">month_type</span> m<span class="special">,</span> <span class="identifier">day_type</span> d<span class="special">)</span><span class="special">;</span></pre>Main constructor with year, month, day. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="id-1_3_14_15_4_6_1_1_1_15-bb"></a><span class="identifier">date</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">ymd_type</span> <span class="special">&amp;</span> ymd<span class="special">)</span><span class="special">;</span></pre>Constructor from a ymd_type structure. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="id-1_3_14_15_4_6_1_1_1_16-bb"></a><span class="identifier">date</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">date_int_type</span> <span class="special">&amp;</span> rhs<span class="special">)</span><span class="special">;</span></pre>Needed copy constructor. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="id-1_3_14_15_4_6_1_1_1_17-bb"></a><span class="identifier">date</span><span class="special">(</span><span class="identifier">date_rep_type</span> rhs<span class="special">)</span><span class="special">;</span></pre>Needed copy constructor. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="id-1_3_14_15_4_6_1_1_1_18-bb"></a><span class="identifier">date</span><span class="special">(</span><span class="identifier">special_values</span> sv<span class="special">)</span><span class="special">;</span></pre>Constructor for infinities, not a date, max and min date. </li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.14.15.4.6.3.4.4"></a><h3>
<a name="id-1_3_14_15_4_6_1_1_1_12-bb"></a><code class="computeroutput">date</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">date_int_type</span> <a name="id-1_3_14_15_4_6_1_1_1_12_1-bb"></a><span class="identifier">julian_day</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the Julian Day number for the date. </li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">day_of_year_type</span> <a name="id-1_3_14_15_4_6_1_1_1_12_2-bb"></a><span class="identifier">day_of_year</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the day of year 1..365 or 1..366 (for leap year) </li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">date_int_type</span> <a name="id-1_3_14_15_4_6_1_1_1_12_3-bb"></a><span class="identifier">modjulian_day</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the Modified Julian Day number for the date. </li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="keyword">int</span> <a name="id-1_3_14_15_4_6_1_1_1_12_4-bb"></a><span class="identifier">week_number</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the iso 8601 week number 1..53. </li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">BOOST_CXX14_CONSTEXPR</span> <span class="identifier">date_int_type</span> <a name="id-1_3_14_15_4_6_1_1_1_12_5-bb"></a><span class="identifier">day_number</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the day number from the calendar. </li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">BOOST_CXX14_CONSTEXPR</span> <a class="link" href="date.html" title="Class date">date</a> <a name="id-1_3_14_15_4_6_1_1_1_12_6-bb"></a><span class="identifier">end_of_month</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return the last day of the current month. </li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
    <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="gregorian_calendar.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.gregorian.greg_date_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bad_day_of_month.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
